# setup the simulation

import pylab
import moose
import numpy
import IzhikevichPlus

context = moose.PyMooseBase.getContext()
dt = 1.0
duration = 2000.0

IzNeuron = IzhikevichPlus.IzhikevichPlus()

# initialize the neuron and simulation
IzNeuron.setupTables()
#IzNeuron.setParams(0.02, 0.25, -65.0, 6.0, -64.0)
IzNeuron.setParams(0.01, 0.2, -65.0, 8.0, -70.0)

# set up the clock
context.setClock(0, dt, 0)
IzNeuron.VmTable.useClock(0)
IzNeuron.injectTable.useClock(0)
IzNeuron.useClock(0)

# construct the input
inputArray = numpy.zeros(int(duration/(dt*1.0)), dtype=numpy.float64)
inputArray[100:1000] = 30
inputArray[1500:] = 30
IzNeuron.setInputTable(inputArray, dt)

# run the simulation
context.reset()
context.step(duration)

VmArray = numpy.array(IzNeuron.VmTable)
injectArray = numpy.array(IzNeuron.injectTable)
pylab.plot(VmArray)
pylab.plot(injectArray)
